<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="icon" href="<%=contextPath%>/static/images/XTlogo.png" type="image/x-icon">
	<link rel="shortcut icon" href="<%=contextPath%>/static/images/XTlogo.png" type="image/x-icon">
	<link rel="stylesheet" type="text/css" href="<%=contextPath%>/static/login/css/bootstrap.min.css" />
	<link rel="stylesheet" type="text/css" href="<%=contextPath%>/static/login/css/login.css" />
	<link rel="stylesheet" type="text/css" href="<%=contextPath%>/static/login/css/normalize.css" />
	<link href="<%=contextPath%>/static/js/sweet/sweetalert.css" rel="stylesheet">
	<!-- jqery -->
	<script src="<%=contextPath %>/js/jquery-1.8.1.min.js"></script>
	<!-- ajax表单提交-->
	<script src="<%=contextPath %>/js/jquery.form.js"></script>
	<!-- 验证 -->
	<script src="<%=contextPath %>/js/jquery.validate.min.js"></script>

	<script src="<%=contextPath%>/static/js/jquery.tips.js"></script>
	<script src="<%=contextPath%>/static/js/sweet/sweetalert-dev.js"></script>
	<script src="<%=contextPath%>/static/js/sweet/sweetalert.min.js"></script>
	<title>系统登录</title>
</head>
<body>
<div class="login-container ">
		<h3 class="first-h" style="color: #FFF; ">${siteName }</h3>
		<!--form-->
		<div class="form-container">
			<div class="form-details">
				<h3 class="form-title">欢迎登录${siteName }</h3>
				<form id="submitf">
					<div class="user-box form-group">
						<span class="usericon glyphicon glyphicon-user"></span>
						<input type="text" class="form-control" id="username" name="username" placeholder="用户名">
					</div>
					<div class="user-box form-group">
						<span class="usericon glyphicon glyphicon-lock"></span>
						<input type="password" class="form-control" id="password" name="password" placeholder="密码">
					</div>
					<div class="form-group">
						<button type="submit">登录</button>
					</div>
				</form>
				<p class="tech-surport" style="font-weight:bold">建议使用ie8以上版本或火狐、谷歌浏览器访问<br>  帮助文档：<a href="javascript:void(0);">点击下载</a></p>
				<p class="tech-help" style="font-weight:bold"></p>
			</div>

		</div>

	</div>
<script>
$(function(){
	$("#submitf").validate({
		rules : {
			username : {
				required : true,
				minlength : 2
			},
			password : {
				required : true,
				minlength :5
			}
		},
		messages : {
			username : {
				required:function(){
					/* $("#username").tips({
						side:3,
						msg:'请输入用户名',
						bg:'#AE81FF',
						time:2,
						y:50
					}); */
				},
				minlength :function(){
					/* $("#username").tips({
						side:3,
						msg:'用户名必须是2个字符以上',
						bg:'#AE81FF',
						time:1,
						y:50
					}); */
				}
			},
			password : {
				required :function(){
					/* $("#password").tips({
						side:3,
						msg:'请输入密码',
						bg:'#AE81FF',
						time:1,
						y:50
					}); */
				},
				minlength :function(){
					/* $("#password").tips({
						side:3,
						msg:'密码必须是5位数上',
						bg:'#AE81FF',
						time:1,
						y:50
					}); */
				}
			}
		},
		 submitHandler:function(form){
			 $(form).ajaxSubmit({
					url:'<%=contextPath%>/logins',
					type:'post',
					dataType:"json",
					success:function(data){
						if(data.code==200){
							location.href = "<%=contextPath%>/index";
						 }else{
							if(data.code==444){
								location.href = "<%=contextPath%>/logout?bs=1";
							}else{
								alert(data.message);
							}
						}
					}
			  }); 
		}
	});
		if(top!=self){  
	          if(top.location != self.location){
	     		 swal({
	        		    title: "登录超时",
	        		    text: "登录超时，请重新登陆",
	        		    type: "warning",
	        		    confirmButtonColor: "#DD6B55",
	        		    confirmButtonText: "确定",
	        		    animation:"slide-from-bottom",
	        		},function (isConfirm){
	        			if(isConfirm){
	        	  		top.location=self.location;   
	        			}
	        		})
	          }
	     }
		
	});
</script>
	</body>

</html>